package indi.gtl.superbrain.adapter;

import java.util.List;

import indi.gtl.superbrain.models.UserInfo;
import indi.gtl.superbrain.R;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class FriendRankAdapter extends BaseAdapter{
	Context context;
	List<UserInfo>list;
	public FriendRankAdapter(Context context,List<UserInfo>list) {
		this.context=context;
		this.list=list;
	}
	
	@Override
	public int getCount() {
		return list.size();
	}

	@Override
	public Object getItem(int arg0) {
		return list.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		
		return arg0;
	}

	@Override
	public View getView(int arg0, View arg1, ViewGroup arg2) {
		arg1=LayoutInflater.from(context).inflate(R.layout.friendrank_layout, null);
		ImageView imageView=(ImageView) arg1.findViewById(R.id.main_secon_image);
		TextView textView=(TextView) arg1.findViewById(R.id.main_second_name);
		TextView view=(TextView) arg1.findViewById(R.id.main_second_score);
		UserInfo info=list.get(arg0);
		imageView.setImageResource(info.head);
		
		textView.setText(info.name);
		view.setText("总分:"+info.sum_score);
		return arg1;
	}

}
